<template>
  <div class="line-chart">
    <div class="axis-x">
      <div v-for="i in xAxis" :key="i" class="tick">{{ i }}</div>
    </div>
    <div class="axis-y">
      <div v-for="i in yAxis" :key="i" class="tick">{{ i }}</div>
    </div>
    <div class="data-points" v-for="point in dataPoints" :key="point.x" :style="{ left: point.x + 'px', top: point.y + 'px' }"></div>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from 'vue';

export default defineComponent({
  name: 'LineChart',
  setup() {
    const xAxis = ref(10);
    const yAxis = ref(5);
    const dataPoints = ref([
      { x: 2, y: 4 },
      { x: 4, y: 6 },
      { x: 6, y: 8 },
      { x: 8, y: 10 },
    ]);

    return {
      xAxis,
      yAxis,
      dataPoints,
    };
  },
});
</script>

<style scoped>
.line-chart {
  position: relative;
  width: 200px;
  height: 200px;
}
.axis-x,
.axis-y {
  position: absolute;
  background-color: #ccc;
}
.axis-x {
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
}
.axis-y {
  top: 0;
  left: 0;
  width: 1px;
  height: 100%;
}
.tick {
  position: absolute;
  background-color: #333;
}
.axis-x .tick:nth-child(odd) {
  left: 20px;
}
.axis-x .tick:nth-child(even) {
  right: 20px;
}
.axis-y .tick:nth-child(odd) {
  top: 20px;
}
.axis-y .tick:nth-child(even) {
  bottom: 20px;
}
.data-points {
  position: absolute;
  width: 10px;
  height: 10px;
  background-color: red;
}
</style>
